#include <stdio.h>
//版本在CMakeLists.txt已经指定
#include <gtk/gtk.h>

static void on_button_clicked(GtkWidget *widget, gpointer data)
{
    g_print("按钮被点击\n");
}

int main(int argc, char *argv[])
{
    GtkWidget *window;
    GtkWidget *button;
    //初始化gtk
    gtk_init(&argc, &argv);
    //创建窗口，两种类型
    //GTK_WINDOW_TOPLEVEL  普通窗口
    //GTK_WINDOW_POPUP     不带标题的窗口
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "聊天窗口");
    gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);
    //gtk_main_quit表示在窗口关掉时，程序结束
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    button = gtk_button_new_with_label("点击我");
    g_signal_connect(button, "clicked", G_CALLBACK(on_button_clicked), NULL);
    //在x11上无法显示，vcxser上
    gtk_container_add(GTK_CONTAINER(window), button);

    //显示窗口
    gtk_widget_show_all(window);

    //让窗口一直显示
    gtk_main();
    return 0;
}